/***********************************************************
* 
*     File Name:  taskSink.cpp
* 
*        Author:  Algolc
* 
*          mail:  17360224@qq.com
* 
*  Created Time:  Tue 10 Jul 2018 06:17:35 PM CST
* 
***********************************************************/

#include <stdlib.h>
#include "zhelpers.h"

int main() {
    //准备接受上下文和套接字
    void* context = zmq_ctx_new();  //创建环境
    void* receiver = zmq_socket(context, ZMQ_PULL);

    zmq_bind(receiver, "tcp://*:5558");
    
    //等待批次开始
    char* rand_str = s_recv(receiver);
    free(rand_str);

    //现在启动时钟
    int64_t start_time = s_clock();
    
    //处理100个确认
    int task_count = 0;
    for (; task_count < 100; ++task_count) {
        char* rand_str = s_recv(receiver);
        free(rand_str);
        if ((task_count / 10) * 10 == task_count) {
            printf(":");
        } else {
            printf(".");
        }

        fflush(stdout);
    }

    printf("Total epalsed time:%d msec\n", (int)(s_clock() - start_time));

    zmq_close(receiver);
    zmq_ctx_destroy(context);

    return 0;
}
